
import { limitDecimal } from '@/utils/valid'
import type { ObjectDirective } from 'vue'

export default {
  mounted (el) {
    el.addEventListener('input', function (e) {
      const value = e.target.value
      const newValue = limitDecimal(value)
      console.log('int', value, newValue)
      e.target.value = newValue
    })
    const input = el.querySelector('input')
    input.addEventListener('blur', function (e) {
      const value = e.target.value
      e.target.value = parseInt(value) ? parseInt(value) + '' : ''
    })
  },
} as ObjectDirective
